using System.IO;
using UnityEngine;

namespace HuaXianQu.ProtoBuffEx.Runtime
{
    public class DefaultIProtoPathConfig : IProtoPathConfig
    {
        string PackagesRootPathName = "Packages";
        public string PackagesFullName => $"{PackagesRootPathName}/{ProtoBuffPackageConfig.PackageNameAll}";
        DirectoryInfo directoryInfo => new DirectoryInfo(PackagesFullName);
        public string PackagesPath => directoryInfo.FullName;

        public bool IsDebug { get; } = true;

        /// <summary>
        /// 是否使用生成的dll，true会将proto脚本打包成dll，反之会将脚本移动到GenerateProtoCSRootPath定义的路径下
        /// </summary>
        public virtual bool IsUsedDLL => false;

        /// <summary>
        /// Excel文件路径
        /// </summary>
        public virtual string ExcelPath => $"{Application.dataPath}/../../Config/Excel/Game";

        /// <summary>
        /// Proto文件路径
        /// </summary>
        public virtual string GenerateProtoPath => $"{Application.dataPath}/../../Config/ProtoFiles";

        /// <summary>
        /// Proto对应的Data文件路径
        /// </summary>
        public virtual string GenerateProtoDataPath => $"{Application.dataPath}/Res/ProtoData";

        /// <summary>
        /// 生成Proto对应的cs脚本路径，只有当IsUsedDLL为false时生效
        /// </summary>
        public virtual string GenerateProtoCsRootPath => "Assets/Scripts/ProtoCSharp";

        /// <summary>
        /// proto脚本生成的dll名字
        /// </summary>
        public virtual string ProtoDllName => $"{ProtoBuffPackageConfig.CompanyName}.ProtoBuffData";

        /// <summary>
        /// 脚本或者dll生成的缓存路径，缓存的文件类型依赖于IsUsedDLL设置。true时为dll，false时为cs脚本 
        /// </summary>
        public virtual string GenerateCsCachePath => $"{Application.dataPath}/../Library/ProtoCache";


        /// <summary>
        ///    Proto生成的dll路径，只有当IsUsedDLL为true时生效
        /// </summary>
        public virtual string GenerateProtoDllPath => $"Assets/Plugins/ProtoBuffData";

#if UNITY_STANDALONE_WIN // Windows 平台。
        string protocName = "Win/protoc";
#elif UNITY_STANDALONE_OSX // macOS 平台。
        string protocName = "OSX/protoc";
#elif UNITY_STANDALONE_LINUX // Linux 平台。
        string protocName = "Linux/protoc";
#else
        string protocName = "Win/protoc";
#endif


        /// <summary>
        /// Proto文件解析工具路径，使用默认就可以，除非有重大改动，插件以内置2024版本编译的exe
        /// </summary>
        public virtual string ProtocPath => $"{PackagesPath}/Editor/Editor Resouces/ProtoTool~/{protocName}";

        /// <summary>
        ///谷歌Protobuf的dll路径，使用默认就可以，除非有重大改动，插件以内置2024版本编译的dll
        /// </summary> 
        public virtual string GoogleProtobufPath => $"{PackagesPath}/Plugins/ProtoBuf/Google.Protobuf.dll";
    }
}